package com.LiL.Wayne.Activity.fragment;

import android.app.ActionBar;
import android.content.Context;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.LiL.Wayne.Activity.R;
import com.LiL.Wayne.Activity.SlidingMenu.ActivityBase;
import com.LiL.Wayne.Activity.SlidingMenu.SlidingMenuBuilderConcrete;
import com.audamob.audasingers.tool.adapter.SwipeyTabsPagerAdapter;
import com.audamob.audasingers.tool.view.ImageResizerUtils;
import com.viewpagerindicator.TabPageIndicator;

public class MainContainerActivityTest extends ActivityBase {

	private static final String[] TITLES = { "Settings", "Videos", "Favorites",
			"Music", "Playlist", "Lyrics", "News", "Tweets", "Bio" };

	private TabPageIndicator mTabs;
	private ViewPager mViewPager;
	public static MainContainerActivityTest activity;

	public static int ITEM_VIDEOS = 0;
	public static int ITEM_MUSICS = 1;
	public static int ITEM_LYRICS = 2;
	public static int ITEM_NEWS = 3;
	public static int ITEM_TWEETS = 4;
	public static int ITEM_BIO = 5;
	public static int ITEM_SETTINGS = 6;

	// Your need to put this method in every Activity class where you want to
	// have sliding menu.
	@Override
	public Class<?> setSlidingMenu() {
		// Each activity can have it's own sliding menu controlling builder
		// class.
		return SlidingMenuBuilderConcrete.class;
	}

	@Override
	public boolean enableHomeIconActionSlidingMenu() {
		return true;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		activity = this;
		setContentView(R.layout.auda_layout_maincontainer_test);
		ActionBar actionBar = getActionBar();
		if (actionBar != null)
			actionBar.setDisplayHomeAsUpEnabled(false);
		ViewGroup mainContainer = (ViewGroup) findViewById(R.id.MainContainer);
		Typeface font = Typeface.createFromAsset(getAssets(), "Cyberverse.otf");

		ChangeCurrentFragment(ITEM_VIDEOS);

		// mViewPager.setOnPageChangeListener(mTabs);
		// mViewPager.setCurrentItem(1);
		ImageResizerUtils.setFont(this, mainContainer, font);

	}

	public static void ChangeCurrentFragment(int i) {


		FragmentManager fragmentManager;
		fragmentManager = activity.getSupportFragmentManager();
		String[] TITLES = CreateTableString(i);
		
		ViewGroup mainContainer = (ViewGroup) activity.findViewById(R.id.MainContainer);
		mainContainer.removeAllViews();
		
		LayoutInflater inflater = (LayoutInflater) activity
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		LinearLayout content = (LinearLayout) inflater.inflate(
				R.layout.auda_swyper_frame, null);
		
		mainContainer.addView(content);

		

		
		ViewPager pager = (ViewPager) mainContainer.findViewById(R.id.viewpager);
		Log.i("TabIndicator_pbm","pager = "+pager);
		
		SwipeyTabsPagerAdapter adapter = new SwipeyTabsPagerAdapter(activity,
				fragmentManager, TITLES, pager, i);

		pager.setAdapter(adapter);

		TabPageIndicator indicator = (TabPageIndicator) mainContainer
				.findViewById(R.id.indicator);
		Log.i("TabIndicator_pbm","indicator = "+indicator);
		
		
		indicator.setViewPager(pager);

	}

	public static String[] CreateTableString(int i) {
		switch (i) {
		case 0:
			String[] tab_0 = {
					activity.getResources().getString(R.string.Video_text),
					activity.getResources().getString(
							R.string.Video_Favorites_text) };
			return tab_0;
		case 1:
			String[] tab_1 = {
					activity.getResources().getString(R.string.Music_text),
					activity.getResources().getString(
							R.string.Music_Playlist_text) };
			return tab_1;
		case 2:
			String[] tab_2 = { activity.getResources().getString(
					R.string.Lyrics_text) };
			return tab_2;
		case 3:
			String[] tab_3 = { activity.getResources().getString(
					R.string.News_text) };
			return tab_3;
		case 4:
			String[] tab_4 = { activity.getResources().getString(
					R.string.Tweets_text) };
			return tab_4;
		case 5:
			String[] tab_5 = { activity.getResources().getString(
					R.string.Bio_text) };
			return tab_5;

		default:
			String[] tab_6 = { activity.getResources().getString(
					R.string.Settings_text) };
			return tab_6;
		}
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub

		super.onResume();

	}

}